package com.zuo.demo01.pojo;

import com.fasterxml.jackson.annotation.JsonFormat;

import java.text.SimpleDateFormat;
import java.util.Date;

public class Blog {

    private Integer id;
    private String title;
    private String url;
    private String image;
    private String content;
    private Catagory catagory;
    private String tags;
    private Integer status;
    private Integer views;
    private Integer enComment;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date updateTime;

    @Override
    public String toString() {
        return "Blog{" +
                "id=" + id +
                ", title='" + title + '\'' +
                ", url='" + url + '\'' +
                ", image='" + image + '\'' +
                ", content='" + content + '\'' +
                ", catagory=" + catagory +
                ", tags='" + tags + '\'' +
                ", status=" + status +
                ", views=" + views +
                ", enComment=" + enComment +
                ", createTime=" + getCreateTime() +
                ", updateTime=" + updateTime +
                '}';
    }

    public Blog(Integer id, String title, String url, String image, String content, Catagory catagory, String tags, Integer status, Integer views, Integer enComment, Date createTime, Date updateTime) {
        this.id = id;
        this.title = title;
        this.url = url;
        this.image = image;
        this.content = content;
        this.catagory = catagory;
        this.tags = tags;
        this.status = status;
        this.views = views;
        this.enComment = enComment;
        this.createTime = createTime;
        this.updateTime = updateTime;
    }

    public Blog() {
    }

    public Blog(Integer id, String title, String url, String image, String content, Catagory catagory, Integer status, Integer views, Integer enComment) {
        this.id = id;
        this.title = title;
        this.url = url;
        this.image = image;
        this.content = content;
        this.catagory = catagory;
        this.status = status;
        this.views = views;
        this.enComment = enComment;
    }

    public Blog(Integer id, String title, String url, String image, String content, Catagory catagory, Integer status, Integer views, Integer enComment, Date createTime, Date updateTime) {
        this.id = id;
        this.title = title;
        this.url = url;
        this.image = image;
        this.content = content;
        this.catagory = catagory;
        this.status = status;
        this.views = views;
        this.enComment = enComment;
        this.createTime = createTime;
        this.updateTime = updateTime;
    }

    public String getTags() {
        return tags;
    }

    public void setTags(String tags) {
        this.tags = tags;
    }


    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Catagory getCatagory() {
        return catagory;
    }

    public void setCatagory(Catagory catagory) {
        this.catagory = catagory;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getViews() {
        return views;
    }

    public void setViews(Integer views) {
        this.views = views;
    }

    public Integer getEnComment() {
        return enComment;
    }

    public void setEnComment(Integer enComment) {
        this.enComment = enComment;
    }

    public String getCreateTime() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        if(this.createTime==null){
            return null;
        }
        /*System.out.println(this.getClass().getSimpleName()+"->"+sdf.format(this.createTime));*/
        return sdf.format(this.createTime);
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}
